<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="box">
			{{1234.34|f1}}
			<div v-for="i in arr">
				<!--{{i/100}}元-->
				{{(i/100).toFixed(2) | f1}}
			</div>
		</div>
	</body>
	<script src="../js/vue.js"></script>
	<script>
		// 学东西，不是说所有的东西都应给使用他，会造成，问题复杂化
		Vue.filter('f1', (str) => {
			var num = parseFloat(str);
			var strOutput = "",
				strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分';
			num += "00";
			var intPos = num.indexOf('.');
			if(intPos >= 0) {
				num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
			}
			strUnit = strUnit.substr(strUnit.length - num.length);
			for(var i = 0; i < num.length; i++) {
				strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1);
			}
			return strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元")
		})
		new Vue({
			el: "#box",
			data: {
				arr: [18900, 17888, 6797, 78679]
			}
		})
	</script>
</html>
